package com.wwmz.pattern.prototype.job;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by wumz on 2020/9/17 17:54
 */
@Data
public class JsonPrototype implements Cloneable {
    private String name;
    private String sex;
    private Integer age;
    private String address;
    private List<String> hobbies;

    public JsonPrototype deepCloneHobbies() {
        JsonPrototype prototype = null;
        try {
            prototype = (JsonPrototype) super.clone();
            JsonPrototype javaObject = JSON.toJavaObject((JSON) JSONObject.toJSON(prototype), JsonPrototype.class);
            return javaObject;
        }catch (Exception e){
            e.printStackTrace();
        }
        return prototype;
    }
}
